﻿using System;
using System.ServiceProcess;
using System.Threading;

namespace ServiceManager_Service
{
    public partial class ServiceManager_Service : ServiceBase
    {
        private Timer _ServiceManagerTimer;
        public ServiceManager_Service()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            this._ServiceManagerTimer = new Timer(new TimerCallback(ServiceManagerTimerCallback), null, 0, Timeout.Infinite);
        }

        protected override void OnStop()
        {
            this._ServiceManagerTimer = null;
        }

        #region Private Methods
        private void ServiceManagerTimerCallback(object state)
        {
            this._ServiceManagerTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
            //do something
            this._ServiceManagerTimer.Change(Properties.Settings.Default.ServiceManager_TimeInterval, Timeout.Infinite);
        }
        #endregion

    }
}
